package com.woniuxy.education.mapper;

import com.woniuxy.education.entity.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface HomeworkAssignmentsMapper {
    //添加一个布置作业信息
    @Insert("insert into homework values(null,#{job_type},#{subject},now(),#{expiration_time},#{status},#{c_id})")
    public void insertHomework(HomeworkAssignments homeworkAssignments);
    //通过布置作业信息id添加具体题目
    @Insert("insert into homework_titleid values(null,#{choose},#{completion},#{answer_questions},#{composition},#{h_id})")
    public void insertHomeworkTitle(HomeworkTitle homeworkTitle);
    //查询作业信息id
    @Select("SELECT id FROM homework WHERE expiration_time=#{expiration_time}")
    String selecthomeworkid(String expirationtime);

    //添加一个考试信息
    @Insert("insert into test_table values(null,#{type},#{subject},now(),#{end_time},#{status},#{level},#{c_id})")
    public void insertTest(TestMessage TestMessage);
    //通过考试信息id添加具体题目
    @Insert("insert into test_titleid values(null,#{choose},#{completion},#{answer_questions},#{composition},#{t_id})")
    public void insertTestTitle(Titleids titleids);
    //查询出考试信息id
    @Select("SELECT * FROM test_table WHERE end_time=#{endtime} and c_id=#{cid}")
    String selectTest(@Param("endtime") String endtime,@Param("cid") int cid);

    //查询出教师信息
    @Select("SELECT * FROM teacher WHERE u_id=#{userid} ")
    Teacher selectteacher(String userid);

    /**
     *查询题目
     * @param
     * @return
     */
    //查指定科目指定数据的选择题的id
    @Select("SELECT id FROM choose_table WHERE SUBJECT=#{subject} LIMIT 0,#{chooseNumber}")
    public List<Integer> pageFindChoose(  HomeworkTypeNumber homeworkTypeNumber);
    //查指定科目指定数据的填空题的id
    @Select("select id from completion_table WHERE SUBJECT=#{subject}  LIMIT 0,#{completionNumber}")
    public List<Integer> pageFindCompletion(  HomeworkTypeNumber homeworkTypeNumber);
    //查指定科目指定数据的解答题的id
    @Select("select id from answer_questions_table WHERE SUBJECT=#{subject}  LIMIT 0,#{answer_questionsNumber}")
    public List<Integer> pageFindAnswer_Questions(HomeworkTypeNumber homeworkTypeNumber);
    //查指定科目指定数据的作文题的id
    @Select("select id from composition_table WHERE SUBJECT=#{subject}  LIMIT 0,#{compositionNumber}")
    public List<Integer> pageFindComposition(HomeworkTypeNumber homeworkTypeNumber);






}
